package laravel;

import entity_model.Entity;
import utils.VirtualFolder;
import utils.titles.Title;
import php.PhpFile;
import php.code.routines.Constructor;
import php.code.routines.PhpClass;

import java.util.LinkedHashMap;

import static php.Php.FILE_MAP;
import static php.code.Visibility.PUBLIC;

public class EntityClass extends PhpClass {
    public final Entity entity;

    public EntityClass(VirtualFolder folder, Title title, String superNameClass, Entity entity) {
        super(title, superNameClass);
        this.entity = entity;

        if (!FILE_MAP.containsKey(getClass()))
            FILE_MAP.put(getClass(), new LinkedHashMap<>());

        setFile(new PhpFile(folder, title, this));

        FILE_MAP.get(getClass()).put(entity, getFile());
    }

    public Entity getEntity() {
        return entity;
    }

    public String getName() {
        return getTitle().toUpperCamel();
    }

    public Constructor getDefaultConstructor() {
        return new Constructor(this, PUBLIC);
    }
}